package com.vim.common.base;

import com.vim.common.model.base.BaseEntity;

import java.util.List;

/**
 * 业务层基类实现类
 */
public class CrudServiceImpl<T extends BaseEntity> implements CrudService<T>{

    private final CrudMapper<T> mapper;

    public CrudServiceImpl(CrudMapper<T> mapper) {
        this.mapper = mapper;
    }

    @Override
    public int save(T entity) {
        return getMapper().save(entity);
    }

    @Override
    public int delete(String id) {
        return getMapper().delete(id);
    }

    @Override
    public int update(T entity) {
        return getMapper().update(entity);
    }

    @Override
    public T find(String id) {
        return getMapper().find(id);
    }

    @Override
    public List<T> findList(T t) {
        return getMapper().findList(t);
    }

    private CrudMapper<T> getMapper() {
        return mapper;
    }
}
